<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="assets/css/stylesheet.css">
<link rel="stylesheet" type="text/css" href="assets/css/fontawesome.min.css">

<title>SAT>IP - Frontend Overview</title>

<script src="assets/js/menu.js"></script>
<script src="assets/js/loadxmldoc.js"></script>
<script src="assets/js/postxmldoc.js"></script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/addtableentry.js"></script>
<script>
	var autoload = 1;
	var xmlLoaded;

	function buildcontent(xmlDoc) {
		var page = "";
		var streams = xmlDoc.getElementsByTagName("streamindex");
		if (streams.length > 0) {
			var size = streams.length;
			for (index = 1; index <= size; index++) {
				var streamID = "stream" + index + " ";
				var visibleStream = xmlDoc.getElementsByTagName("stream" + index)[0];
				var attached = xmlDoc.querySelector(streamID + "attached").innerHTML;
				var status = xmlDoc.querySelector(streamID + "status").innerHTML;
				if (attached == "yes") {
					if (status == 31) {
						page += '<tr class="table-success">';
					} else {
						page += '<tr class="table-info">';
					}
				} else {
					page += "<tr>";
				}
				// Add shortcut to Frontend Info Pages
				page += '<td align="left"> <a href="frontend.html#' + streamID + '">' + xmlDoc.querySelector(streamID + 'streamindex').innerHTML + '</a></td>';
				page += addTableEntry(xmlDoc, streamID + "enable");
				page += addTableEntry(xmlDoc, streamID + "frontendname");
				page += addTableEntry(xmlDoc, streamID + "type");
				page += addTableEntry(xmlDoc, streamID + "owner");
				page += addTableEntry(xmlDoc, streamID + "spc");
				page += addTableEntry(xmlDoc, streamID + "totalCCErrors");
				var input = xmlDoc.querySelector(streamID + "tunefreq");
				if (input) {
					page += addTableEntry(xmlDoc, streamID + "tunefreq");
				} else {
					page += addTableEntry(xmlDoc, streamID + " transformation " + "transformFreq");
				}

				page += addTableEntry(xmlDoc, streamID + "delsys");
				page += addTableEntry(xmlDoc, streamID + "pathname");
				page += addTableEntry(xmlDoc, streamID + "networkname");
				page += addTableEntry(xmlDoc, streamID + "channelname");
				page += "</tr>";
			}
		}
		return page;
	}

	function updatePage() {
		loadXMLDoc("SatPI.xml");
	}

	// function called when xml is loaded
	function xmlloaded(xml) {
		if (autoload == 1) {
			xmlLoaded = xml;
			document.getElementById("body").innerHTML = buildcontent(xml);
//			$('#body').append('<tr class="table-info"><td align="left">' + '5' + '</td><td/></tr>');
		}
	}
</script>

</head>
<body>
<div id="menu"></div>

<div class="p-1">
<div class="window-start container border rounded-bottom">
	<div class="window-name">
		<p>Frontend Overview</p>
	</div>
	<div class="p-1 table-responsive table-text-size">
		<table class="table table-bordered table-sm">
			<thead class="thead-light"><tr>
				<th class="col-xs-1">#</th>
				<th class="col-xs-1">Enable</th>
				<th class="col-xs-1">Name</th>
				<th class="col-xs-1">Type</th>
				<th class="col-xs-1">Owner</th>
				<th class="col-xs-1">Packets</th>
				<th class="col-xs-1">CC Error</th>
				<th class="col-xs-1">Frequency (kHz)</th>
				<th class="col-xs-1">Delivery System</th>
				<th class="col-xs-3">Path</th>
				<th class="col-xs-3">Network Name</th>
				<th class="col-xs-3">Channel Name</th>
			</tr></thead>
			<tbody id="body"></tbody>
		</table>
	</div>
	<script>
		// make menu
		document.getElementById("menu").innerHTML = buildmenu();
		setMenuItemActive("frontendoverview");

		updatePage();

		// Call the ajax refresh each refresh_time seconds
		var refresh_time = 2000;
		setInterval("updatePage()", refresh_time);

	</script>
</div>
</div>
</body>
</html>
